package com.example.generator.service.impl;

import com.example.generator.entity.FieldInfo;
import com.example.generator.entity.vo.DataxParament;
import com.example.generator.enums.GeneratorTypeEnum;
import com.example.generator.service.IDataxGeneratorService;
import com.example.generator.utils.DataSourceUtil;
import com.example.generator.utils.GeneratorUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author：QPX
 * @date：2024-05-15-9:51
 */
@Service
public class IDataxGeneratorServiceImpl implements IDataxGeneratorService {
    @Override
    public void generatorJson(DataxParament dataxParament) throws Exception {
        DataSourceUtil.init(dataxParament.getDataSourceConfig());
        List<FieldInfo> field = DataSourceUtil.getField(dataxParament.getTableConfig());
        if (dataxParament.getDataxConfig().getReader() != null)
            if ("mysqlReader".equals(dataxParament.getDataxConfig().getReader())){
                GeneratorUtil.generatorDataxJson(dataxParament, GeneratorTypeEnum.DATAX_MYSQL_READER.getType(),field);
            }
    }
}
